import Cookies from 'js-cookie';

// 定义默认选项
const defaultOptions = {
    secure: process.env.VUE_APP_COOKIE_SECURE === 'true',
    path: '/'
};
console.log('sss', defaultOptions)
// 合并默认选项和传入的选项
const withDefaults = (options = {}) => ({ ...defaultOptions, ...options });

// 封装设置 Cookie 的函数
export function setCookie(name, value, options = {}) {
    console.log('sss', defaultOptions)
    Cookies.set(name, value, withDefaults(options));
}

// 封装获取 Cookie 的函数
export function getCookie(name) {
    return Cookies.get(name);
}

// 封装删除 Cookie 的函数
export function removeCookie(name, options = {}) {
    Cookies.remove(name, withDefaults(options));
}